package com.imu.purse.modules.trade.entity;

import java.math.BigDecimal;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

import org.hibernate.validator.constraints.NotBlank;

import com.alibaba.fastjson.annotation.JSONField;
import com.imu.common.validator.group.AddGroup;
import com.imu.common.validator.group.UpdateGroup;
import com.imu.core.base.BaseEntity;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;


/**
 * 交易流水
 * 
 * @author sunhongwei
 * @email sunhongwei@jshijian.com
 * @date 2018-03-22 10:33:21
 * Copyright (c) 2017 武汉极时间科技有限公司 版权所有 
 * Jshijian aloha CO.,LTD. All Rights Reserved. 
 */
@Data
@Table(name = "imu_trade_log")
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = false)
public class TradeLogEntity extends BaseEntity
{
	private static final long serialVersionUID = 1L;
	
	//主键ID
	@Id
	@Column(name="id")
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@NotNull(message="主键不存在无法更新", groups = {UpdateGroup.class})
	@ApiModelProperty(value = "主键ID", hidden = true)
	private Long id;
	
	//付款账号
	@JSONField(ordinal = 1)
	@Column(name="pay_account")
	@NotBlank(message="付款账号不能为空", groups = {AddGroup.class, UpdateGroup.class})
	@ApiModelProperty(value="付款账号", name="payAccount", required = true, example="13800000000")
	private String payAccount;
	
	//付款用户名
	@JSONField(ordinal = 2)
	@Column(name="pay_name")
	@NotBlank(message="付款用户名不能为空", groups = {AddGroup.class, UpdateGroup.class})
	@ApiModelProperty(value = "付款用户名", name="payName", required = true, example="张三")
	private String payName;
	
	//收款账号
	@JSONField(ordinal = 3)
	@Column(name="rec_account")
	@NotBlank(message="收款账号不能为空", groups = {AddGroup.class, UpdateGroup.class})
	@ApiModelProperty(value="收款账号", name="payAccount", required = true, example="13800000000")
	private String recAccount;
	
	//收款用户名
	@JSONField(ordinal = 4)
	@Column(name="rec_name")
	@NotBlank(message="收款用户名不能为空", groups = {AddGroup.class, UpdateGroup.class})
	@ApiModelProperty(value = "收款用户名", name="recName", required = true, example="张三")
	private String recName;
	
	//订单号
	@JSONField(ordinal = 5)
	@Column(name="order_no")
	@NotBlank(message="订单号不能为空", groups = {AddGroup.class, UpdateGroup.class})
	@ApiModelProperty(value = "订单号", name="orderNo", required = true, example="201801010100111")
	private String orderNo;
	
	//订单类型
	@JSONField(ordinal = 6)
	@Column(name="order_type")
	@ApiModelProperty(value = "订单类型", name="orderType", required = true, example="0")
	@NotNull(message="订单类型不能为空", groups = {AddGroup.class, UpdateGroup.class})
	@Min(value=0, message="订单类型必须大于等于0", groups = {AddGroup.class, UpdateGroup.class})
	private Integer orderType;
	
	//状态 0 支付中 1 成功 -1失败
	@JSONField(ordinal = 7)
	@Column(name="order_state")
	@ApiModelProperty(value = "状态", hidden = true)
	private Integer orderState;
	
	//交易余额
	@JSONField(ordinal = 8)
	@Column(name="money")
	@ApiModelProperty(value = "交易余额", name="money", required = true, example="100")
	@NotNull(message="交易余额不能为空", groups = {AddGroup.class, UpdateGroup.class})
	@Min(value=1, message="交易余额必须大于等于1", groups = {AddGroup.class, UpdateGroup.class})
	private BigDecimal money;
	
	//交易时间
	@JSONField(ordinal = 9)
	@Column(name="order_create")
	@ApiModelProperty(value = "交易时间", name="orderCreate", required = true, example="100")
	private Long orderCreate;
	
	//交易签名
	@JSONField(ordinal = 10)
	@Column(name="sign")
	@ApiModelProperty(value = "签名", hidden = true)
	private String sign;
	
	//描述详情
	@JSONField(ordinal = 11)
	@Column(name="detail")
	@ApiModelProperty(value = "描述", hidden = true)
	private String detail;
}
